# import requests
# from config import BASE_HOST
#
#
# class Reg_api:
#     def __init__(self):
#
#         self.url_img =BASE_HOST+"/common/public/verifycode1/123332123123"
#         self.url_phone = BASE_HOST+"/member/public/sendSms"
#         self.sess = requests.Session()
#
#     def get_img_code(self):
#         '''
#         获取图片验证码
#         :return:
#         '''
#         self.sess.get(self.url_img)
#
#     def post_phone_code(self,mobile):
#         '''
#         获取短信验证码
#         :param mobile: 获取短信的手机号码
#         :return: 响应体的json格式
#         '''
#         body = {"phone": mobile,
#                 "imgVerifyCode": "8888",
#                 "type": "reg"}
#         resp = self.sess.post(self.url_phone,data=body)
#         return resp
#     def post_reg(self):
#         pass
# 1、导包
from bs4 import BeautifulSoup

data = """
<html> 
    <head>
        <title>黑马程序员</title>
    </head> 
    <body>
        <p id="test01">软件测试</p>
        <p id="test02">2020年</p>
        <a href="/api.html">接口测试</a>
        <a href="/web.html">Web自动化测试</a> 
        <a href="/app.html">APP自动化测试</a>
</body>
</html>
"""
# 2、获取BeautifulSoup对象
bs = BeautifulSoup(data,"html.parser")
# 3、调用相关方法
# 获取title标签的全部数据
title = bs.title
print(title)

# # 获取title标签的内容
title1 = bs.title.string
print(title1)
# # 获取p标签的第一条数据，id属性的值
print(bs.p.get("id"))
# 获取所有a标签
print(bs.findAll("a"))

# 获取所有a标签的href属性的值
list_01 = []
for i in bs.findAll("a"):
   w =  i.get("href")
   list_01.append(w)
print(list_01)





